const express = require("express");
const multer = require("multer");
const fs = require("fs");
const router = express.Router()

router.post(
    '/ctimg',
    multer({
        dest: '../bsapp/public/image/CT'
    }).array('file', 1),
    function(req, res, next) {
        let files = req.files;
        let file = files[0];
        let fileInfo = {};
        let path = "../bsapp/public/image/CT" + Date.now().toString() + "_" + file.originalname;
        fs.renameSync("../bsapp/public/image/CT" + file.filename, path);
        //获取文件基本信息
        fileInfo.type = file.mimetype;
        fileInfo.name = file.originalname;
        fileInfo.size = file.size;
        fileInfo.path = path;
        res.send({
            code: 200,
            msg: "OK",
            data: fileInfo,
        });
    }
)




module.exports = router